#!/bin/bash
URL=http://www.baidu.com/s?wd=%CC%EC%C6%F8
baidutq=/tmp/mypogoda
weather=/tmp/pogoda.txt
_scripts_dir_=~/.conkycolors/scripts
_img_dir_=~/.conkycolors/images/

w3m -dump $URL > $baidutq
end=`cat -n $baidutq | grep "发布 7天预报" | cut -f1 | sed 's/ *//'`

head -n $end $baidutq | tail -n 6 > $weather
#iconv -f gbk -t utf-8 $weather > $weather   # 转化为utf-8编码
cnd=`$_scripts_dir_/conkytq.sh 1 | cut -d " " -f1`

if echo "$cnd" | grep -E -i -q '转'; then
        cnd=$(echo "$cnd" | awk -F "转" '{print $1}')
fi

case $cnd in
'多云')
        cond='CloudyPartly.png' ;;
 '晴')
    cond='Sunny.png' ;;
 '晴间多云')
    cond='CloudyLightPartly.png' ;;
 '阴')
    cond='Cloud.png' ;;
 '小雨')
    cond='RainLight.png' ;;
 '中雨')
    cond='Rain.png' ;;
 '大雨')
    cond='RainHeavy.png' ;;
 '暴雨')
    cond='RainHeavy.png' ;;
 '阵雨')
    cond='RainWindy.png' ;;
 '雷阵雨')
    cond='Shower1.png' ;;
 '大雪')
    cond='SnowHeavy.png' ;;
 '雨加雪')
    cond='RainMixedSnow.png' ;;
 '中雪')
    cond='Snow.png' ;;
 '小雪')
    cond='SnowLight.png' ;;
esac

prefstr='${image '
poststr=' -s 64x64 -p 120,8 }'
echo $prefstr$_img_dir_$cond$poststr
